//package com.example.shangjinlieren.provider;
//
//import com.example.shangjinlieren.ResourceTable;
//import com.example.shangjinlieren.compontents.ImageNetWork;
//import com.example.shangjinlieren.entity.moneyList.OfferAReward;
//import ohos.aafwk.ability.AbilitySlice;
//import ohos.agp.components.*;
//
//import java.util.List;
//
//public class demoMoneyListProvider extends BaseItemProvider {
//    private List<OfferAReward> list;
//    private AbilitySlice abilitySlice;
////    private List<Component> components = new ArrayList<>();
//    public demoMoneyListProvider(List<OfferAReward> list, AbilitySlice abilitySlice) {
//        this.list = list;
//        this.abilitySlice = abilitySlice;
//    }
//
//    @Override
//    public int getCount() {
//        return   list == null ? 0 : list.size();
//    }
//
//    @Override
//    public Object getItem(int i) {
////        if (list != null && i >= 0 && i < list.size()){
////            return list.get(i);
////        }
////        return null;
//        return list.get(i);
//    }
//
//    @Override
//    public long getItemId(int i) {
//        return i;
//    }
//
//    @Override
//    public Component getComponent(int i, Component component, ComponentContainer componentContainer) {
//        System.out.println("i==========="+i+component);
//     Component cpt = component;
//      DynamicOfferAReward dynamicOfferAReward = null;
//     if (component==null){
//         cpt = LayoutScatter.getInstance(abilitySlice.getContext()).parse(ResourceTable.Layout_offerAReward,
//                 null, false);
//         dynamicOfferAReward = new DynamicOfferAReward(cpt);
//
//         cpt.setTag(dynamicOfferAReward);//将布局模板写入缓存  下次调用使用 不用重复查询模板
//     } else {
//         //如果有就直接走这里减少内存占用
//         //第二次进来有缓存
//         dynamicOfferAReward =(DynamicOfferAReward) cpt.getTag();
//     }
//        OfferAReward offerAReward = list.get(i);
//        new ImageNetWork(abilitySlice,dynamicOfferAReward.img,offerAReward.getImg()).start();
//        dynamicOfferAReward.img.setScaleMode(Image.ScaleMode.INSIDE);
//        dynamicOfferAReward.messageNum.setText(offerAReward.getMessageNum()+"");
//        dynamicOfferAReward.title.setText(offerAReward.getTitle());
//        dynamicOfferAReward.star.setText(offerAReward.getStar()+"");
//        dynamicOfferAReward.nums.setText(offerAReward.getNums()+"");
//        return cpt;
//    }
//    public static class DynamicOfferAReward{
//        Image img;
//        Text nums;
//        Text messageNum;
//        Text title;
//        Text star;
//        DynamicOfferAReward(Component itemComponent) {
//            img =(Image) itemComponent.findComponentById(ResourceTable.Id_offer_a_reward_img);
//            nums =(Text) itemComponent.findComponentById(ResourceTable.Id_offer_a_reward_nums);
//            messageNum =(Text) itemComponent.findComponentById(ResourceTable.Id_offer_a_reward_messageNum);
//            title =(Text) itemComponent.findComponentById(ResourceTable.Id_offer_a_reward_title);
//            star =(Text) itemComponent.findComponentById(ResourceTable.Id_offer_a_reward_star);
//
//        }
//    }
//
//}
